package com.snail.eunms;

/**
 * @author Monica
 * @description
 * @date 2025/7/24 21:16
 */
public enum OrderType {
    JOIN_FEE(0, "入队费"),
    SUBSCRIPTION(1, "订阅费"),
    SHARED_EXPENSE(2, "购买课程费"),
    OTHER(3, "其他");

    private final int code;
    private final String name;

    OrderType(int code, String name) {
        this.code = code;
        this.name = name;
    }

    // 根据编码获取枚举实例
    public static OrderType fromCode(int code) {
        for (OrderType type : OrderType.values()) {
            if (type.code == code) {
                return type;
            }
        }
        throw new IllegalArgumentException("未知订单类型编码: " + code);
    }

    // 根据编码获取名称
    public static String getNameByCode(int code) {
        OrderType type = fromCode(code);
        return type.name;
    }

    // Getters
    public int getCode() {
        return code;
    }

    public String getName() {
        return name;
    }
}